package WaiBao;

import java.util.Arrays;

public class WangTingTing {
    public static void main(String[] args) {
        String[] name = {"张晓伟(班长)", "荔枝(副班长)", "小李(学习委员)", "李志豪(纪律委员)", "小黑", "小白", "齐小胖", "张小嘎", "胖墩", "翠花", "凌青霞", "范彬彬",
                "李冰冰", "张杰", "周冬雨", "佟大为", "张国立", "倪大红", "曾志伟", "洪金宝", "周润发", "吴征宇", "凌肖豪", "梁家辉", "张家辉", "古天乐", "丁俊晖", "奥沙利文",
                "斯坦丁", "王婷婷(学生)"};//考生本人:王婷婷(学生)
        int[] age = {19, 20, 21, 18, 20, 20, 19, 21, 21, 19, 18, 21, 20, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 20};//考生本人年龄:20


        double[] piba1 = {84, 68, 76, 91, 90, 74, 74, 89, 81, 74, 91, 87, 85, 79, 65, 68, 69, 90, 86, 80, 92, 91, 95, 65, 75, 74, 94, 74, 80, 95};
        double[] piba2 = {77, 77, 65, 86, 80, 67, 74, 64, 83, 81, 72, 77, 66, 84, 65, 65, 76, 69, 76, 98, 72, 71, 95, 86, 75, 88, 84, 64, 81, 95};
        double[] piba3 = {68, 61, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 84, 95};

        double qianbi1 ;//代表每个学生的总分
        double qianbi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            qianbi1  = piba1[i] + piba2[i] +piba3[i];
//            qianbi2 = (qianbi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + qianbi1);
//            System.out.println(name[i] + "的平均分为:" + qianbi2);
//        }


        double shoubiao1 = 0,shoubiao2 = 0;
        double[] zouma = new double[30];
//        for (int i = 0; i < 30; i++) {
//            shoubiao1= piba1[i] +  piba2[i] +  piba3[i];
//            shoubiao2 = (shoubiao1* 1.0) / 3;
//            zouma[i] = shoubiao2;
//        }
//
//        for (int i = 0; i < zouma.length - 1; i++) {
//            for (int j = 0; j <  zouma.length - i - 1; j++) {
//                if (zouma[j] <zouma[j + 1]) {
//                    double tep =  zouma[j];
//                    zouma[j] = zouma[j + 1];
//                    zouma[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( zouma[i]);
//        }




        double jielun1 = 0, jielun2 = 0,jielun3 = 0;//计算每门课的平均分
        double jiabing1 = 0, jiabing2 = 0, jiabing3 = 0;//计算每门课标准差
        double xiaoxiao1 = 0, xiaoxiao2 = 0, xiaoxiao3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < piba1.length; i++) {
            he +=piba1[i];
        }
        jielun1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +jielun1);
        double Sum = 0;
        for (int i = 0; i < piba2.length; i++) {
            Sum +=piba2[i];
        }
        jielun2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +jielun2);
        double sum = 0;
        for (int i = 0; i <piba3.length; i++) {
            sum +=piba3[i];
        }
        jielun3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +jielun3);

        //标准差
        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <piba1.length; i++) {
            c1 += (piba1[i] - jielun1) * (piba1[i] - jielun1);
        }
        jiabing1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + jiabing1);
        for (int i = 0; i <piba2.length; i++) {
            c2 += (piba2[i] - jielun2) * (piba2[i] -jielun2);
        }
        jiabing2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" + jiabing2);

        for (int i = 0; i <piba3.length; i++) {
            c3 += (piba3[i] - jielun3) * (piba3[i] - jielun3);
        }
        jiabing3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +jiabing3);
////////
//        Arrays.sort(piba1);
//        Arrays.sort(piba2);
//        Arrays.sort(piba3);
//        xiaoxiao1 = (piba1[15] +piba2[16]) * 1.0 / 2;
//        xiaoxiao2 = (piba2[15] + piba2[16]) * 1.0 / 2;
//        xiaoxiao3 = (piba3[15] + piba3[16]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  xiaoxiao1);
//        System.out.println("农业设施设计与制造的中位数为:" + xiaoxiao2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + xiaoxiao3);






    }
}
